import { INDEXEDDB } from 'localforage'
import type { FaceDetectorOptions } from '@mediapipe/tasks-vision'
import type { DeepPartial, LocalForageOptions, PdDefault } from '@type/index'
export const config = {
  /**
   * 试戴配置
   */
  tryOn: {
    /**
     * 试戴输出的宽高比
     * @default 3 / 4
     */
    sceneAspect: 'full' as number | 'full',
    /**
     * pd放大默认列表
     */
    pdScale: [
      {
        label: '74',
        value: 0.92,
      },
      {
        label: '72',
        value: 0.93,
      },
      {
        label: '71',
        value: 0.94,
      },
      {
        label: '70',
        value: 0.95,
      },
      {
        label: '69',
        value: 0.96,
      },
      {
        label: '68',
        value: 0.97,
      },
      {
        label: '67',
        value: 0.98,
      },
      {
        label: '66',
        value: 0.99,
      },
      {
        label: '65',
        value: 1,
      },
      {
        label: '64',
        value: 1.01,
      },
      {
        label: '63',
        value: 1.02,
      },
      {
        label: '62',
        value: 1.03,
      },
      {
        label: '61',
        value: 1.04,
      },
      {
        label: '60',
        value: 1.05,
      },
      {
        label: '59',
        value: 1.06,
      },
      {
        label: '58',
        value: 1.07,
      },
      {
        label: '57',
        value: 1.08,
      },
      {
        label: '56',
        value: 1.09,
      },
      {
        label: '55',
        value: 1.1,
      },
      {
        label: '54',
        value: 1.11,
      },
    ] as PdDefault[],
    defaultScale: 65,
    enablePdScale: true,
    sliderColor: '#ff0000',
    /**
     * 将摄像头的像素重新输出为此宽度，高度将根据**sceneAspect**进行自动计算
     */
    detectWidth: 480,
  },
  /**
   * 开启对比
   */
  enableContrast: false,
  showFPS: true,
  videoAppend: false as false | keyof HTMLElementTagNameMap | string,
  /**
   *  three的配置
   */
  three: {
    /**
     * 开启摄像机自由控制
     * @default false
     */
    control: false,
    wireframe: false,
    cameraZoom: {
      min: 1,
      max: 1.5,
    },
  },
  /**
   * mediapipe所需要的文件
   */
  filesPath: {
    /**
     * mediapipe所需要的js文件
     * @default '/model/js/vision_wasm_nosimd_internal.js'
     */
    js: '/model/js/vision_wasm_nosimd_internal.js',
    /**
     * mediapipe所需的wasm文件
     * @default '/model/wasm/vision_wasm_nosimd_internal.wasm'
     */
    wasm: '/model/wasm/vision_wasm_nosimd_internal.wasm',
    /**
     * mediapipe所需的task文件
     * @default '/model/task/face_landmarker.task'
     */
    task: '/model/task/face_landmarker.task',
  },
  /**
   * mediapipe所需的文件大小(用来计算进度条)
   */
  filesBytes: {
    js: 204137,
    wasm: 9448638,
    task: 3758596,
  },
  /**
   * mediapipe 配置参考https://ai.google.dev/edge/mediapipe/solutions/vision/face_landmarker?hl=zh-cn
   */
  Mediapipe: {
    runningMode: 'VIDEO',
    minFaceDetectionConfidence: 0.5,
    minFacePresenceConfidence: 0.5,
    minTrackingConfidence: 0.5,
    baseOptions: {
      delegate: 'GPU',
    },
  } as FaceDetectorOptions,
  /**
   * localForage持久化配置
   */
  localforage: {
    driver: INDEXEDDB,
    name: 'try-glasses',
    storeName: 'files',
  } as LocalForageOptions,
}
export type Options = typeof config
export type PartialOptions = DeepPartial<Options>
